package com.scorpio.order.service.impl;

import com.scorpio.common.service.impl.BaseServiceImpl;
import com.scorpio.order.domain.OrderEntity;
import com.scorpio.order.domain.OrderSnsEntity;
import com.scorpio.order.mapper.OrderSnsMapper;
import com.scorpio.order.service.OrderSnsServer;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

@Service
public class OrderSnsServerImpl extends BaseServiceImpl<OrderSnsMapper, OrderSnsEntity> implements OrderSnsServer {
    @Override
    public OrderSnsEntity selectByOrderSn(String orderSn) {
        return baseDao.selectByOrderSn(orderSn);
    }

    @Override
    @Transactional
    public int save(OrderEntity entity) {
        OrderSnsEntity snsEntity = new OrderSnsEntity();
        snsEntity.setOid(entity.getId());
        snsEntity.setOrder_sn(entity.getOrderSn());
        snsEntity.setCreate_time(new Date());
        return baseDao.insert(snsEntity);
    }
}
